<?php
//包含数据库配置文件
include '../../public/dbconfig.php';
//包含函数库文件
include '../../public/functions.php';
//调用函数  链接数据库
$link = con();
//接收要删除的id
$pid = $_GET['pid'];

//查询分区下 是否有版块 如果有则不删除  没有则删除
$csql = "select id,cname,pid from cate where pid={$pid}";
//执行sql
$cres = mysqli_query($link, $csql);
if($cres && mysqli_num_rows($cres)){
	echo '<script>alert("该分区下有版块，不能删除");window.location.href="list.php";</script>';
}else{
	//准备sql
	$psql = "delete from part where id={$pid}";
	//执行sql
	$pres = mysqli_query($link, $psql);
	//判断执行结果
	if($pres){
		echo '<script>alert("删除成功");window.location.href="list.php";</script>';
	}else{
		echo '<script>alert("删除失败");window.location.href="list.php";</script>';
	}
}
//关闭数据库链接
mysqli_close($link);

